<html>
<head>
    <title>政府端</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../../../style.css">
    <link rel="stylesheet" href="../../../swipebox.css">
    <style>
        body {
            background: #F2F2F2;
        }

        .main-head {
            background: #fff;
            padding-left: 10px;
            padding-top: 10px;
            margin-bottom: 0px;
            border: solid 1px #fff;
        }

        .chart-outer {
            height: 200px;
        }

        .page-top {
            margin: 30px 0 0px 30px;

        }
    </style>
</head>
<body>
<div class="page" id="page-elesafe">

    <div class="page-title">安全监督检查,安全监督检查记录</div>
    <div class="page-main">
        <el-row>
            <el-col :span="24" style="    background: #ffffff;">
                <el-form :inline="true" class="page-top">
                    <el-form-item label="计划名称">
                        <el-input placeholder="计划名称" style="width: 150px;" v-model="planName"></el-input>
                    </el-form-item>
                    <el-form-item label="检查类型">
                        <el-select style="width: 150px;" v-model="planType">
                            <el-option
                                    v-for="item in DangerousData"
                                    :key="item.Id"
                                    :label="item.Name"
                                    :value="item.Id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="检查人员姓名">
                        <el-input placeholder="检查人员姓名" style="width: 150px;" v-model="userName"></el-input>
                    </el-form-item>
                    <el-form-item label="企业名称">
                        <el-input placeholder="企业名称" style="width: 150px;" v-model="projectName"></el-input>
                    </el-form-item>
                    <el-form-item label="企业负责人">
                        <el-input placeholder="企业负责人" style="width: 150px;" v-model="manager"></el-input>
                    </el-form-item>
                    <el-form-item label="行业类型">
                        <el-select style="width: 150px;" v-model="catigory">
                            <el-option
                                    v-for="item in BusinessList"
                                    :key="item.cid"
                                    :label="item.cname"
                                    :value="item.cid">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="检查时间" prop="startTime">
                        <el-col :span="11">
                            <el-date-picker type="datetime" placeholder="开始时间" v-model="startTime"
                                            value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%;"></el-date-picker>
                        </el-col>
                        <el-col class="line" :span="2">-</el-col>
                        <el-col :span="11">
                            <el-date-picker type="datetime" placeholder="结束时间" v-model="endTime"
                                            value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%;"></el-date-picker>
                        </el-col>
                    </el-form-item>
                    <el-form-item>
                        <el-button @click="btnSearch" type="primary">查询</el-button>
                        <!--<el-button @click="exportData" type="primary">导出</el-button>-->
                    </el-form-item>
                </el-form>
                <el-table border stripe style="width: 100%;margin-bottom: 50px" :data="tabData">
                    <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
                    <el-table-column prop="planName" label="计划名称" align="center">
                    </el-table-column>
                    <el-table-column prop="projectName" label="单位名称" align="center">
                    </el-table-column>
                    <el-table-column prop="manager" label="单位法人" align="center">
                    </el-table-column>
                    <el-table-column prop="catigoryName" label="行业类型" align="center">
                    </el-table-column>
                    <el-table-column prop="planTypeName" label="检查类型" align="center">
                    </el-table-column>
                    <el-table-column prop="isSysInto" label="是否系统入驻" align="center">
                        <template slot-scope="scope">
                            <div v-if="scope.row.isSysInto == '0'">
                                <el-tag size="medium" type="success">否</el-tag>
                            </div>
                            <div v-if="scope.row.isSysInto == '1'">
                                <el-tag size="medium" type="success">是</el-tag>
                            </div>
                        </template>
                    </el-table-column>

                    <el-table-column prop="userName" label="检查人姓名" align="center">
                    </el-table-column>
                    <el-table-column prop="missionTime" label="检查日期" align="center">
                        <template slot-scope="scope" v-if="scope.row.missionTime">
                            <el-tag size="medium">{{scope.row.missionTime.replace("T"," ")}}</el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column prop="missionDetail" label="检查反馈" align="center">
                    </el-table-column>
                    <el-table-column prop="ischeck" label="检查状态" align="center">
                        <template slot-scope="scope">
                            <div v-if="scope.row.ischeck == '0'">
                                <el-tag size="medium" type="success">否</el-tag>
                            </div>
                            <div v-else-if="scope.row.ischeck == '1'">
                                <el-tag size="medium" type="success">是</el-tag>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="现场图片">
                        <template slot-scope="scope">
                            <template v-if="scope.row.file">
                                <a :href="imageUrl+scope.row.file" class="swipebox" title="ESC键退出">
                                    <el-popover
                                            placement="right"
                                            width="300"
                                            trigger="hover"
                                            popper-class="popClass">
                                        <img :src="imageUrl+scope.row.file"
                                             style="max-width:600px;max-height: 380px "/>
                                        <img :src="imageUrl+scope.row.file" slot="reference"
                                             style="max-width:80px;max-height: 80px "/>
                                    </el-popover>
                                </a>
                            </template>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" align="center">
                        <template slot-scope="scope">

                            <template v-if="scope.row.ischeck==0">
                               未检查不可验收
                            </template>
                            <template v-if="scope.row.ischeck==1">
                                <template v-if="scope.row.assessFlag==-1">
                                    <el-button round size="mini" icon="el-icon-share"
                                               @click="openAssess(scope.row.Id,scope.row.wf_tasktime)">
                                        验收
                                    </el-button>
                                </template>
                                <template v-else>
                                    <el-button round size="mini" icon="el-icon-share" @click="openAssessed(scope.row)">
                                        已验
                                    </el-button>
                                </template>

                            </template>
                        </template>
                    </el-table-column>
                </el-table>
            </el-col>
        </el-row>

        <el-dialog title="验收明细" :visible.sync="assessedFormVisible" :show-close="false">
            <el-form :model="Assessed">
                <template v-if="Assessed.assess">
                    <el-form-item label="验收内容:" :label-width="formLabelWidth">
                        {{Assessed.assess}}
                        <!--                    <el-input v-model="form.wf_reason" autocomplete="off" disabled></el-input>-->
                    </el-form-item>
                    <el-form-item label="验收类型:" :label-width="formLabelWidth">
                        {{Assessed.assessFlag==0?'不合格':'合格'}}
                    </el-form-item>
                    <el-form-item label="验收时间:" :label-width="formLabelWidth">
                        <templeate v-if="Assessed.assessTime">
                            {{Assessed.assessTime.replace("T"," ")}}
                        </templeate>
                    </el-form-item>
                </template>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="assessedFormVisible=false">确定</el-button>
            </div>
        </el-dialog>
        <el-dialog title="验收" :visible.sync="assessFormVisible" :show-close="false">
            <el-form :model="Assess">
                <el-form-item label="验收结论" :label-width="formLabelWidth">
                    <el-input v-model="Assess.assess" autocomplete="off" type="textarea"></el-input>
                </el-form-item>
                <el-form-item label="验收结果" :label-width="formLabelWidth">
                    <el-radio v-model="Assess.assessFlag" label="0">不合格</el-radio>
                    <el-radio v-model="Assess.assessFlag" label="1">合格</el-radio>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="assessFormVisible = false">取 消</el-button>
                <el-button @click="insertAssess">确定</el-button>
            </div>
        </el-dialog>
    </div>
    <div class="page-footer">
        <el-pagination background layout="prev, pager, next" :pagesize="pagesize" :total="totalCount"
                       :current-page.sync="pageno" @current-change="onChangePage">
        </el-pagination>
    </div>
</div>


<!-- import Vue before Element -->
<script src="../../../assets/bundle.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script type='text/javascript' src='../../../assets/jquery-1.11.2.min.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../assets/echarts.min.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../js/common.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../js/component.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../assets/jquery.swipebox.min.js' charset='utf-8'></script>
<script>
    let loading;
    var vuePage = new Vue({
        el: '#page-elesafe',
        data: {
            formLabelWidth: '120px',
            currentPage: 1,
            tabData: [],
            dialogFormVisible: false,
            detailFormVisible: false,
            assessFormVisible: false,
            assessedFormVisible: false,
            form: {},
            headers: {
                uid: '',
                token: '',
            },
            uploadData: {},
            param: {
                pagesize: 10,
                pageno: 1,
                wf_processflag: '',
                wf_objType: '',
                wf_businesstype: '',
                wf_projectNo: '',
            },
            pagesize: 10,
            totalCount: 0,
            pageno: 1,
            day: '',
            Assess: {
                Id: '',
                assess: '',
                assessFlag: '',
                wf_tasktime: ''
            },
            Assessed: {
                assess: '',
                assessFlag: '',
                assessTime: ''
            },
            checkDatalist: {},
            checkpagesize: 10,
            checkpageno: 1,
            checktotalCount: 0,
            wf_tasktime: '',
            wf_Id: '',
            dialogcheckdataVisible: false,
            BusinessList: [],
            DangerousData: [
                {Name: '直接选择或搜索选择', Id: 0},
                {Name: '重点检查', Id: 1},
                {Name: '一般检查', Id: 2},
                {Name: '专项检查', Id: 3}
            ],
            startTime: '',
            endTime: '',
            planName: '',
            planType: '',
            userName: '',
            projectName: '',
            manager: '',
            catigory: '',
            imageUrl:''
        },
        methods: {
            btnSearch: function () {
                this.getWorkFlow();
            },
            exportData() {
                // var date = this.day.split("-");
                // SiteConfig.account.projectNo
                const d = new Date(this.day);
                var year = d.getFullYear();
                var month = d.getMonth() + 1;

                var param = {
                    // SiteConfig.account.projectNo
                    wf_projectNo: SiteConfig.account.projectNo,
                    UserId: SiteConfig.account.id,
                    year: year,
                    month: month
                };
                HttpUtil.get('WorkFlow/ExportWorkFlow', param).success((res) => {
                    this.$message.success('导出成功');
                    window.location = SiteConfig.webApiset + res.data;
                })
            },
            openAssessed: function (row) {
                this.assessedFormVisible = true;
                this.Assessed.assess = row.assess;
                this.Assessed.assessFlag = row.assessFlag;
                this.Assessed.assessTime = row.assessTime;
            },
            openAssess: function (id, wf_tasktime) {
                this.assessFormVisible = true;
                this.Assess.Id = id;
                // this.Assess.wf_tasktime = wf_tasktime;
                this.Assess.assessUserId = SiteConfig.account.id;
            },
            insertAssess: function () {
                HttpUtil.get('GovernmentPlan/PlanAssess', this.Assess).success((r) => {
                    if (r.state == 0) {
                        vuePage.$message({
                            type: 'success',
                            message: '验收成功!'
                        });
                        this.assessFormVisible = false;
                        vuePage.getWorkFlow();
                    } else {
                        vuePage.$message.error('验收失败!');
                    }
                })
            },
            onChangePage(page) {
                this.pageno = page;
                this.getWorkFlow();
            },
            getWorkFlow() {
                var param = {};
                if (this.startTime)
                    param.startTime = this.startTime;
                if (this.endTime)
                    param.endTime = this.endTime;
                if (this.planName)
                    param.planName = this.planName;
                if (this.planType)
                    param.planType = this.planType;
                if (this.userName)
                    param.userName = this.userName;
                if (this.projectName)
                    param.projectName = this.projectName;
                if (this.manager)
                    param.manager = this.manager;
                if (this.catigory)
                    param.catigory = this.catigory;

                param.pagesize = this.pagesize;
                param.pageno = this.pageno;
                param.UserId = SiteConfig.account.id;
                HttpUtil.get('GovernmentPlan/PlanMinutesList', param).success((r) => {
                    if (r.state == 0) {
                        vuePage.totalCount = r.total;
                        var datalist = r.data;

                        var BusinessListData = this.BusinessList;
                        for (var i = 0; i < datalist.length; i++) {
                            for (var j = 0; j < BusinessListData.length; j++) {
                                if (datalist[i].catigory == BusinessListData[j].cid) {
                                    datalist[i].catigoryName = BusinessListData[j].cname;
                                }
                            }
                        }

                        var DangerousData = this.DangerousData;
                        for (var i = 0; i < datalist.length; i++) {
                            for (var j = 0; j < DangerousData.length; j++) {
                                if (datalist[i].planType == DangerousData[j].Id) {
                                    datalist[i].planTypeName = DangerousData[j].Name;
                                }
                            }
                        }
                        vuePage.tabData = datalist;
                    }
                    else {
                        this.$message({type: 'error', message: r.errMsg});
                    }


                })
            },
        },
        created: function () {

        },
        mounted: function () {
            this.imageUrl = SiteConfig.webApiset;
            HttpUtil.get('CodeController/BusinessList').success((r) => {
                if (r.state == 0) {
                    vuePage.BusinessList = r.data;
                    vuePage.BusinessList.splice(0, 0, {
                        BusinessList: [], PlanData: [],
                        Controlflag: "1",
                        YX_ID: "",
                        c_seqno: null,
                        cflag: null,
                        cid: "",
                        cmemo: "Business22",
                        cname: "未选行业",
                        maxLevel: 1,
                        pid: "Business",
                        useflag: "1",
                    });
                }
            })
            this.imageUrl = SiteConfig.webApiset;
            this.headers = {
                uid: SiteConfig.account.uId,
                token: SiteConfig.account.accessToken
            };
            this.day = TimeUtil.convertToString(new Date()).substr(0, 7);
            this.getWorkFlow();
        },
    });
</script>

</body>
</html>

